@import (reference) '../style/variables.less';

.gen-device-box-shadow(@scale) {
  box-shadow: 0 0 0 @s-device-border-width * @scale #090a0d, 0 0 0 @s-device-shell-width * @scale #9fa3a8,
    0 4px 20px @s-device-shell-width * @scale rgba(0, 0, 0, 0.1);
}
.gen-device-style(@scale) {
  width: @s-device-width * @scale;
  min-width: @s-device-width * @scale;
  height: @s-device-width * @scale * @s-device-ratio;
}

.@{prefix}-device {
  display: flex;
  flex-direction: column;
  width: @s-device-width;
  min-width: @s-device-width;
  height: @s-device-width * @s-device-ratio;
  min-height: 100%;
  max-height: 100%;

  &.@{prefix}-device-fixed {
    position: sticky;
    top: @s-device-gap-top;
    margin-left: @s-content-margin;
    border-radius: 32px;
    min-height: initial;
    max-height: initial;

    .gen-device-box-shadow(1);

    @media only screen and (max-width: 1440px) {
      .gen-device-box-shadow(0.9);
    }

    @media only screen and (max-width: 1360px) {
      .gen-device-box-shadow(0.8);
    }
  }

  overflow: hidden;
  .gen-device-style(1);

  background-color: #fff;

  &::-webkit-scrollbar {
    opacity: 0;
  }

  @media only screen and (max-width: 1440px) {
    .gen-device-style(0.9);
  }

  @media only screen and (max-width: 1360px) {
    .gen-device-style(0.8);
  }

  @media only screen and (max-width: 960px) {
    display: none;
  }

  &[data-mode='site'] {
    top: @s-nav-height + @s-device-shell-width + @s-device-gap-top;
  }

  &-status {
    border-bottom: solid 1px #f2f2f2;
  }

  &-status,
  &-action {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 22px;
  }

  &-status {
    height: 30px;
    color: #222;
    font-size: 12px;
    font-weight: 500;
    user-select: none;

    span {
      display: inline-block;
      width: 60px;

      &:nth-child(2) {
        text-align: center;
      }
    }

    // battery
    &::after {
      content: '';
      display: inline-block;
      margin-left: 42px;
      width: 14px;
      height: 5px;
      border-radius: 1px;
      background: #50d664;
      box-shadow: 0 0 0 1px #fff, 0 0 0 2px #999;
    }
  }

  &-action {
    height: 40px;
    background: #f3f3f3;
    border-top: 1px solid #e3e3e3;

    > a,
    > button {
      padding: 0;
      width: 16px;
      height: 16px;
      box-sizing: content-box;
      border: 2px solid transparent;
      transition: opacity 0.2s, background 0.2s;
      outline: none;
      cursor: pointer;

      &:hover {
        opacity: 0.8;
      }

      &:active {
        opacity: 0.9;
      }

      &[role='refresh'] {
        background-position-x: -144px;
      }

      &[role='open-demo'] {
        background-position-x: -126px;
      }

      &[role='qrcode'] {
        position: relative;
        z-index: 1;
        background-position-x: -218px;

        > canvas {
          position: absolute;
          bottom: 120%;
          left: 50%;
          border: 4px solid #fff;
          box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
          box-sizing: content-box;
          transition: all 0.2s ease-in-out;
          transform: translateX(-50%) scale(0);
          transform-origin: center bottom;
        }

        &:hover > canvas,
        &:focus > canvas {
          transform: translateX(-50%) scale(1);
        }
      }
    }
  }

  > iframe {
    flex: 1;
    border: 0;
  }
}
